package leetcode;

import java.util.HashMap;

public class FirstUniqChar {
    public static void main(String[] args) {
        FirstUniqChar firstUniqChar = new FirstUniqChar();
        System.out.println(firstUniqChar.firstUniqChar("aadadaad"));
        HashMap<Character, Integer> map = new HashMap<>();
    }

    public char firstUniqChar(String s) {
        int[] arr = new int[26];
        char[] chars = s.toCharArray();
        for (char c : chars) {
            arr[c - 97]++;
        }
        for (char c : chars) {
            if (arr[c - 97] == 1) {
                return c;
            }
        }
        return ' ';
    }
}
